package Service;

import Bean.Aircraft;
import Bean.Page;
import Dao.AircraftDao;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-14
 * Time: 12:29
 */
public class AircraftService {
    private AircraftDao aircraftDao = new AircraftDao();

    public int selectByAircraftId (String aircraftId) {
        Aircraft aircraft = new Aircraft();
        aircraft.setAircraftId(aircraftId);
        aircraft =aircraftDao.selectById(aircraft);
        if(aircraft == null) {
            return 0;
        }
        return 1;
    }

    public Aircraft selectById (String aircraftId) {
        Aircraft aircraft = new Aircraft();
        aircraft.setAircraftId(aircraftId);
        return aircraftDao.selectById(aircraft);
    }

    public boolean insert(Aircraft aircraft) {
        return aircraftDao.insert(aircraft);
    }

    public Page selectList(int pageNo, int pageSize) {
        Page page = new Page();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        page.setTotalRecords(aircraftDao.size());
        page.setList(aircraftDao.select(pageNo,pageSize));
        return page;
    }

    public boolean update(Aircraft aircraft) {
        return aircraftDao.update(aircraft);
    }
}
